<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>CSS之选择器的深入理解 | 乐枫的草稿箱</title><meta name="author" content="乐枫"><meta name="copyright" content="乐枫"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="CSS day11. css简介css 层叠样式表 Cascading Style Sheets设置 文本内容的字体 大小 等设置图片的大小美化html的样式，布局网页   1.3 css 语法规范选择器 和 声明   选择器{样式} p给谁更改样式    h1 给h1修改样式；键值对；属性和属性之间分号结束写在&lt;head&gt;&lt;&#x2F;head&gt;之间    2.css 基础选择器2">
<meta property="og:type" content="article">
<meta property="og:title" content="CSS之选择器的深入理解">
<meta property="og:url" content="https://lefengpiaoling.github.io/archives/11b21107.html">
<meta property="og:site_name" content="乐枫的草稿箱">
<meta property="og:description" content="CSS day11. css简介css 层叠样式表 Cascading Style Sheets设置 文本内容的字体 大小 等设置图片的大小美化html的样式，布局网页   1.3 css 语法规范选择器 和 声明   选择器{样式} p给谁更改样式    h1 给h1修改样式；键值对；属性和属性之间分号结束写在&lt;head&gt;&lt;&#x2F;head&gt;之间    2.css 基础选择器2">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://lefengpiaoling.github.io/img/top.webp">
<meta property="article:published_time" content="2022-09-20T16:21:35.000Z">
<meta property="article:modified_time" content="2022-09-20T16:22:53.912Z">
<meta property="article:author" content="乐枫">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://lefengpiaoling.github.io/img/top.webp"><link rel="shortcut icon" href="https://cdn.jsdelivr.net/gh/lefengpiaoling/piclefeng/img/lefeng.jpg"><link rel="canonical" href="https://lefengpiaoling.github.io/archives/11b21107"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//hm.baidu.com"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><meta name="baidu-site-verification" content="code-1YvEIWGUMg"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?4efeb503e3439e4a9188f93a94e5f120";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":false,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'CSS之选择器的深入理解',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-09-21 00:22:53'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="css/style.css"><meta name="generator" content="Hexo 6.3.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://cdn.jsdelivr.net/gh/lefengpiaoling/piclefeng/img/lefeng.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">4</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">0</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);" rel="external nofollow noreferrer"><i class="fa-fw fa fa-heartbeat"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/Gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/img/top.webp')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">乐枫的草稿箱</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);" rel="external nofollow noreferrer"><i class="fa-fw fa fa-heartbeat"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/Gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">CSS之选择器的深入理解</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-09-20T16:21:35.000Z" title="发表于 2022-09-21 00:21:35">2022-09-21</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-09-20T16:22:53.912Z" title="更新于 2022-09-21 00:22:53">2022-09-21</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">970</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>3分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="CSS之选择器的深入理解"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="CSS-day1"><a href="#CSS-day1" class="headerlink" title="CSS day1"></a>CSS day1</h1><h2 id="1-css简介"><a href="#1-css简介" class="headerlink" title="1. css简介"></a>1. css简介</h2><p>css 层叠样式表 Cascading Style Sheets<br>设置 文本内容的字体 大小 等<br>设置图片的大小<br>美化html的样式，布局网页  </p>
<h3 id="1-3-css-语法规范"><a href="#1-3-css-语法规范" class="headerlink" title="1.3 css 语法规范"></a>1.3 css 语法规范</h3><p><font color=red>选择器 和 声明</font>  </p>
<p>选择器{样式} p<br>给谁更改样式</p>
<p><img src="https://xd-imgsubmit.oss-cn-beijing.aliyuncs.com/images/20210717205949.png" alt="20210717205949"><br><img src="https://xd-imgsubmit.oss-cn-beijing.aliyuncs.com/images/20210717210232.png" alt="20210717210232">  </p>
<p>h1 给h1修改样式；<br>键值对；<br>属性和属性之间分号结束<br>写在<code>&lt;head&gt;&lt;/head&gt;</code>之间   </p>
<h2 id="2-css-基础选择器"><a href="#2-css-基础选择器" class="headerlink" title="2.css 基础选择器"></a>2.css 基础选择器</h2><h3 id="2-1-选择器的作用"><a href="#2-1-选择器的作用" class="headerlink" title="2.1 选择器的作用"></a>2.1 选择器的作用</h3><p>选择器的作用 ： 选对标签</p>
<h3 id="2-2-选择分类"><a href="#2-2-选择分类" class="headerlink" title="2.2 选择分类"></a>2.2 选择分类</h3><p>基础选择器： 标签选择器，类选择器， id选择器，通配符选择器 </p>
<h3 id="2-3-标签选择器"><a href="#2-3-标签选择器" class="headerlink" title="2.3 标签选择器"></a>2.3 标签选择器</h3><p>html标签名作为选择的对象<br>示例：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">标签名&#123;</span><br><span class="line">    属性1：值；</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>全部的标签的属性都会被更改  </p>
<h3 id="2-4-类选择器"><a href="#2-4-类选择器" class="headerlink" title="2.4 类选择器"></a>2.4 类选择器</h3><p>选出其中的一个或者几个标签 对他们更改样式<br>以$.$开头</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">.类名&#123;</span><br><span class="line">    属性1：值</span><br><span class="line">&#125;</span><br><span class="line">```  </span><br><span class="line">利用clss 属性调用class类    </span><br><span class="line">调用方式：  </span><br><span class="line">![20210719145607](https://xd-imgsubmit.oss-cn-beijing.aliyuncs.com/images/20210719145607.png)  </span><br><span class="line">谁想使用，在标签中直接设置class 的名字为 定义好的类的名字 </span><br><span class="line"></span><br><span class="line">不能使用标签的名字作为类的属性 </span><br><span class="line"></span><br><span class="line">**多类名**  </span><br><span class="line">一个class有多个名字</span><br><span class="line">1. 多类名的使用方式  </span><br><span class="line">   ```&lt;div class=&quot;red font2o&quot;&gt;&lt;/div&gt;``` </span><br><span class="line"></span><br><span class="line">    空格隔开</span><br><span class="line">    定义不同的类，在调用是，多类名使用  </span><br><span class="line">    减少代码量</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">### 2.5 id选择器  </span><br><span class="line"></span><br><span class="line">id属性设置id选择器，id选择器以 # 定义  </span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>#id名字{<br>    属性1：属性值；<br>}</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">调用：</span><br></pre></td></tr></table></figure>
<p>id &#x3D; 名字  </p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">区别：</span><br><span class="line">样式#定义，结构id调用，只能使用一次， 别人切勿使用  一次性的  </span><br><span class="line">和class选择器的区别在于，id选择器只能使用一次，唯一性元素的使用  </span><br><span class="line"></span><br><span class="line">### 2.6 通配符选择器  </span><br><span class="line">更改所有标签的格式</span><br><span class="line"></span><br><span class="line">$*$ 定义 </span><br><span class="line"></span><br><span class="line">### 2.7 基础选择器总结  </span><br><span class="line">![20210719152658](https://xd-imgsubmit.oss-cn-beijing.aliyuncs.com/images/20210719152658.png)   </span><br><span class="line"></span><br><span class="line">## 3. css字体属性 </span><br><span class="line">### 3.1 字体系列</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>p{<br>    font-family:**;<br>}</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">多个字体 用 英文输入法 , 隔开  </span><br><span class="line"></span><br><span class="line">### 3.2 字体大小  </span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>p{<br>    font-size:**;<br>}</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">谷歌浏览器 默认 16px  </span><br><span class="line">标题标签 需要单独设置  </span><br><span class="line"></span><br><span class="line">### 3.3 字体加粗 </span><br><span class="line"></span><br><span class="line">font-weight: normal, bold ,number</span><br><span class="line"></span><br><span class="line">### 3.4 文字样式  </span><br><span class="line"></span><br><span class="line">&lt;code&gt;</span><br><span class="line">font-style:</span><br><span class="line">&lt;em&gt;nihao &lt;/em&gt;</span><br><span class="line">&lt;/code&gt;    </span><br><span class="line"></span><br><span class="line"></span><br><span class="line">### 3.5 复合属性： </span><br><span class="line">&lt;pre&gt;</span><br><span class="line">body&#123;  </span><br><span class="line">    font:font-style font-weight font-size font-family;   </span><br><span class="line">&#125;</span><br><span class="line">&lt;/pre&gt;</span><br><span class="line">注意顺序 ，不能错乱顺序  </span><br><span class="line">必须保留 font-size 和 font-family  </span><br><span class="line">### 3.6 属性总结 </span><br><span class="line"></span><br><span class="line">![20210719161156](https://xd-imgsubmit.oss-cn-beijing.aliyuncs.com/images/20210719161156.png)  </span><br><span class="line">字体size 的单位：px   </span><br><span class="line"></span><br><span class="line">## 4. 文本属性 </span><br><span class="line"></span><br><span class="line">文本外观 ：颜色， 对齐文本，装饰文本，文本缩进，行间距  </span><br><span class="line"></span><br><span class="line">### 4.1 文本颜色:</span><br><span class="line"></span><br><span class="line">&lt;pre&gt; &#123;</span><br><span class="line">color: **;</span><br><span class="line">&#125;&lt;/pre&gt;  </span><br><span class="line">16进制；   # FF0000  </span><br><span class="line">rgb:</span><br><span class="line">&lt;pre&gt;</span><br><span class="line">    color:(,,);</span><br><span class="line">&lt;/pre&gt;  </span><br><span class="line"></span><br><span class="line">### 4.2 文本对齐 </span><br><span class="line">text-align :水平对齐方式</span><br><span class="line">left,right,center  </span><br><span class="line">盒子中的文字水平对齐  </span><br><span class="line"></span><br><span class="line">### 4.3  装饰文本 </span><br><span class="line"></span><br><span class="line">text-decoration:underline</span><br><span class="line"></span><br><span class="line">none;  </span><br><span class="line">overline;  </span><br><span class="line">&lt;u&gt;underline&lt;/u&gt;  </span><br><span class="line">~~删除线~~ </span><br><span class="line"></span><br><span class="line"></span><br><span class="line">### 4.4 文本缩进  </span><br><span class="line">text-indent</span><br><span class="line">&lt;pre&gt;</span><br><span class="line">div&#123;</span><br><span class="line">    text-indent:20px;</span><br><span class="line">&#125;</span><br><span class="line">&lt;/pre&gt;  </span><br><span class="line"></span><br><span class="line">文本首行缩进 20px缩进值</span><br><span class="line"></span><br><span class="line">em: 相对单位，相对于当前文本 font-size的相对大小   </span><br><span class="line"></span><br><span class="line">### 4.5 行间距 </span><br><span class="line">line-height:</span><br><span class="line">&lt;pre?&gt;</span><br><span class="line">p&#123;</span><br><span class="line">    line-height:20px;</span><br><span class="line">&#125;</span><br><span class="line">&lt;/pre&gt;</span><br><span class="line"></span><br><span class="line">![20210719165159](https://xd-imgsubmit.oss-cn-beijing.aliyuncs.com/images/20210719165159.png) </span><br><span class="line">改变上下两个间距的距离 </span><br><span class="line"></span><br><span class="line">### 4.6 总结</span><br><span class="line">![20210719165741](https://xd-imgsubmit.oss-cn-beijing.aliyuncs.com/images/20210719165741.png)  </span><br><span class="line"></span><br><span class="line"></span><br><span class="line">## 5. css的引入方式 </span><br><span class="line">行内样式表，嵌入式</span><br><span class="line">### 5.1 行内样式表</span><br><span class="line">在 元素标签内部修改样式</span><br><span class="line"></span><br><span class="line">### 5.2 内部样式表  </span><br><span class="line">在html内部 style 定义样式 一般放在```&lt;head&gt;```标签之前 </span><br><span class="line">html并没有分离  </span><br><span class="line"></span><br><span class="line">### 5.3 外部样式表  </span><br><span class="line">适合样式比较多的代码 </span><br><span class="line"></span><br><span class="line">1.新建.css文件  </span><br><span class="line">只有样式 没有标签  </span><br><span class="line">2. 引入.css文件</span><br><span class="line">在html页面中，使用 ```&lt;link&gt;```标签，引入文件</span><br></pre></td></tr></table></figure>
<link rel="stylesheet" href="css文件路径">
```
### 5.4 总结

<p><img src="https://xd-imgsubmit.oss-cn-beijing.aliyuncs.com/images/20210719171243.png" alt="20210719171243"></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://lefengpiaoling.github.io">乐枫</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://lefengpiaoling.github.io/archives/11b21107.html">https://lefengpiaoling.github.io/archives/11b21107.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="external nofollow noreferrer" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://lefengpiaoling.github.io" target="_blank">乐枫的草稿箱</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="/img/top.webp" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="https://cdn.jsdelivr.net/gh/lefengpiaoling/piclefeng/img/6aa61ea6d32d2975dae713ad7ed3772.jpg" rel="external nofollow noreferrer" target="_blank"><img class="post-qr-code-img" src="https://cdn.jsdelivr.net/gh/lefengpiaoling/piclefeng/img/6aa61ea6d32d2975dae713ad7ed3772.jpg" alt="wechat"/></a><div class="post-qr-code-desc">wechat</div></li><li class="reward-item"><a href="https://cdn.jsdelivr.net/gh/lefengpiaoling/piclefeng/img/82e33a79989ff81c5850cd2e764ae9a.jpg" rel="external nofollow noreferrer" target="_blank"><img class="post-qr-code-img" src="https://cdn.jsdelivr.net/gh/lefengpiaoling/piclefeng/img/82e33a79989ff81c5850cd2e764ae9a.jpg" alt="alipay"/></a><div class="post-qr-code-desc">alipay</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="next-post pull-full"><a href="/archives/c95afcba.html"><img class="next-cover" src="/img/top.webp" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">HTML表格及表单的使用</div></div></a></div></nav><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="lv-container" data-id="city" data-uid="MTAyMC81NzMwNi8zMzc3MA=="></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://cdn.jsdelivr.net/gh/lefengpiaoling/piclefeng/img/lefeng.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">乐枫</div><div class="author-info__description"></div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">4</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">0</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><a id="card-info-btn" target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/lefengpiaoling"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/lefengpiaoling" rel="external nofollow noreferrer" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="https://blog.csdn.net/qq_45985929?type=blog" rel="external nofollow noreferrer" target="_blank" title="CSDN"><i class="fa fa-book-open"></i></a><a class="social-icon" href="tencent://AddContact/?fromId=45&amp;fromSubId=1&amp;subcmd=all&amp;uin=2674604735&amp;website=www.oicqzone.com" rel="external nofollow noreferrer" target="_blank" title="QQ"><i class="fab fa-qq"></i></a><a class="social-icon" href="mailto:2674604735@qq.com" rel="external nofollow noreferrer" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#CSS-day1"><span class="toc-number">1.</span> <span class="toc-text">CSS day1</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-css%E7%AE%80%E4%BB%8B"><span class="toc-number">1.1.</span> <span class="toc-text">1. css简介</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-3-css-%E8%AF%AD%E6%B3%95%E8%A7%84%E8%8C%83"><span class="toc-number">1.1.1.</span> <span class="toc-text">1.3 css 语法规范</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-css-%E5%9F%BA%E7%A1%80%E9%80%89%E6%8B%A9%E5%99%A8"><span class="toc-number">1.2.</span> <span class="toc-text">2.css 基础选择器</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#2-1-%E9%80%89%E6%8B%A9%E5%99%A8%E7%9A%84%E4%BD%9C%E7%94%A8"><span class="toc-number">1.2.1.</span> <span class="toc-text">2.1 选择器的作用</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-2-%E9%80%89%E6%8B%A9%E5%88%86%E7%B1%BB"><span class="toc-number">1.2.2.</span> <span class="toc-text">2.2 选择分类</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-3-%E6%A0%87%E7%AD%BE%E9%80%89%E6%8B%A9%E5%99%A8"><span class="toc-number">1.2.3.</span> <span class="toc-text">2.3 标签选择器</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-4-%E7%B1%BB%E9%80%89%E6%8B%A9%E5%99%A8"><span class="toc-number">1.2.4.</span> <span class="toc-text">2.4 类选择器</span></a></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/archives/11b21107.html" title="CSS之选择器的深入理解"><img src="/img/top.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="CSS之选择器的深入理解"/></a><div class="content"><a class="title" href="/archives/11b21107.html" title="CSS之选择器的深入理解">CSS之选择器的深入理解</a><time datetime="2022-09-20T16:21:35.000Z" title="发表于 2022-09-21 00:21:35">2022-09-21</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/archives/c95afcba.html" title="HTML表格及表单的使用"><img src="/img/top.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="HTML表格及表单的使用"/></a><div class="content"><a class="title" href="/archives/c95afcba.html" title="HTML表格及表单的使用">HTML表格及表单的使用</a><time datetime="2022-09-20T16:18:06.000Z" title="发表于 2022-09-21 00:18:06">2022-09-21</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/archives/833fa472.html" title="HTML知识点总结“"><img src="/img/top.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="HTML知识点总结“"/></a><div class="content"><a class="title" href="/archives/833fa472.html" title="HTML知识点总结“">HTML知识点总结“</a><time datetime="2022-09-20T16:10:40.000Z" title="发表于 2022-09-21 00:10:40">2022-09-21</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/archives/4a17b156.html" title="Hello World"><img src="/img/top.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Hello World"/></a><div class="content"><a class="title" href="/archives/4a17b156.html" title="Hello World">Hello World</a><time datetime="2022-09-18T14:39:40.086Z" title="发表于 2022-09-18 22:39:40">2022-09-18</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2016 - 2022 By 乐枫</div><div class="footer_custom_text">我相信我可以，但我一直在路上，所以我有无限的可能！！</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.autoSpacingPage()
  else {
    getScript('https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js')
      .then(() => {
        pangu.autoSpacingPage()
      })
  }
}

function panguInit () {
  if (false){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguInit)</script><script src="/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>function loadLivere () {
  if (typeof LivereTower === 'object') {
    window.LivereTower.init()
  }
  else {
    (function(d, s) {
        var j, e = d.getElementsByTagName(s)[0];
        if (typeof LivereTower === 'function') { return; }
        j = d.createElement(s);
        j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
        j.async = true;
        e.parentNode.insertBefore(j, e);
    })(document, 'script');
  }
}

if ('Livere' === 'Livere' || !true) {
  if (true) btf.loadComment(document.getElementById('lv-container'), loadLivere)
  else loadLivere()
}
else {
  function loadOtherComment () {
    loadLivere()
  }
}</script></div><div class="aplayer no-destroy" data-id="60198" data-server="netease" data-type="playlist" data-fixed="true" data-autoplay="true"> </div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/metingjs/dist/Meting.min.js"></script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = ["meta[property=\"og:image\"]","meta[property=\"og:title\"]","meta[property=\"og:url\"]","head > title","#config-diff","#body-wrap","#rightside-config-hide","#rightside-config-show",".js-pjax"]

var pjax = new Pjax({
  elements: 'a:not([target="_blank"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:send', function () {

  // removeEventListener scroll 
  window.tocScrollFn && window.removeEventListener('scroll', window.tocScrollFn)
  window.scrollCollect && window.removeEventListener('scroll', scrollCollect)

  typeof preloader === 'object' && preloader.initLoading()
  document.getElementById('rightside').style.cssText = "opacity: ''; transform: ''"
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

  typeof disqusjs === 'object' && disqusjs.destroy()
})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  // google analytics
  typeof gtag === 'function' && gtag('config', '', {'page_path': window.location.pathname});

  // baidu analytics
  typeof _hmt === 'object' && _hmt.push(['_trackPageview',window.location.pathname]);

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/live2dw/assets/koharu.model.json"},"display":{"position":"right","width":145,"height":315},"mobile":{"show":true,"scale":0.5},"react":{"opacityDefault":0.7,"opacityOnHover":0.8},"log":false});</script></body></html>